<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
 * Football Referees extension for Joomleague
 * @version $Id:show_player.tpl.php 98 2008-02-25 23:38:14Z julien.vonthron $
 * @package JlgFootballReferees
 * @copyright Copyright (C) 2007 Julien Vonthron. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * JlgFootballReferees is free software and parts of it may contain or be derived from the
 * GNU General Public License or other free or open source software licenses.
 * 
 * contact: julien.vonthron[at]gmail.com 
 *   
 * Joomleague is a League Management and Prediction Game for Joomla!
 * Homepage: http://www.joomleague.de 
 *  
 */
?>

<div id="joomleague">

<!-- Header with Project Name-->
<?php if ($overall_config['show_project_heading'] == "1") { ?>
<div class="componentheading" <?php if ($overall_config['show_print_button'] == "1") echo 'style="float:left;"';?>><?php echo $season->name; ?></div>
<!-- Druckfunktion -->
<?php if ($overall_config['show_print_button'] == "1") {
HTML_joomleague::PrintIcon( $row, $params, false, '' );
};?>
<!-- Druckfunktion Ende -->
<?php } ?>
<!-- Header END -->

<br />
<?php 

// Display players
if ( count( $rows > 0 ) )
{ 
	$sums = array();
  $colspan = 2;
  if ( $referee_config['show_born'] ) $colspan++;
  if ( $referee_config['show_nation'] ) $colspan++;
  ?>
  <table id="projectreferees" align="center" border="0" cellpadding="3" cellspacing="0">
  <thead>
    <tr>
      <td style="width:40%; text-align:left;" class="sortable ascend" abbr="link_column"><?php echo _JL_REFEXT_NAME; ?></td>
      
      <?php if ( $referee_config['show_born'] ): ?>
      <td style="text-align:center;"><?php echo _JL_REFEXT_BIRTHDAY; ?></td>
      <?php endif; ?>
      
      <?php if ( $referee_config['show_nation'] ): ?>
      <td style="text-align:center;" class="sortable"><?php echo _JL_REFEXT_COUNTRY; ?></td>
      <?php endif; ?>
      
	  <td width="5px" style="text-align:center;" class="sortable" abbr="int"><?php echo _JL_REFEXT_GAMECOUNT_SMALL; ?></td>
	  
	  <?php foreach ($events AS $key => $ev) {?>
      <td width="5px" style="text-align:center;" class="sortable" abbr="int">
        <?php if ($ev->eventtype->icon): ?>
        <img src="<?php echo _JOOMLA_JL_LIVE_SITE; ?>/images/joomleague/event_icons/<?php echo $ev->eventtype->icon;?>" alt="<?php echo $ev->eventtype->name; ?>" title="<?php echo $ev->eventtype->name; ?>" />
        <?php else: ?>
        <?php echo $ev->eventtype->name; ?>
        <?php endif; ?>
      </td>
    <?php } ?>
    </tr>
  </thead>
  <tbody>
  <?php
  $k = 0;
  $position = "";
  for ($i=0, $n=count( $rows ); $i < $n; $i++) 
  {
    $row = &$rows[$i];
        
    // Display referee rows
    ?>
    <tr class="<?php echo ($k == 0)? 'sectiontableentry1' : 'sectiontableentry2'; ?>">
      <td nowrap="nowrap">
          <a href="<?php echo sefRelToAbs(JL_COMPONENT_LINK."&amp;func=showSeasonReferee&amp;p=$joomleague->id&amp;id=$row->id".JL_ITEMID_SUFFIX);?>">
          <?php printf("%s, %s",$row->lastname,$row->firstname);?></a>
      </td>   
      
      <?php if ( $referee_config['show_born'] ): ?>
      <td nowrap="nowrap" style="text-align:center;">
        <?php printf("%s", mbiFormatDate($row->birthday,_JL_REFEXT_BIRTHDAY_FORMAT)); ?>
      </td>
      <?php endif; ?>
      
      <?php if ( $referee_config['show_nation'] ): ?>
      <td style="text-align:center;" nowrap="nowrap">
        <?php
        if ( $row->nation )
        {
          $thiscountry = new Country($database);
          $thiscountry->load($row->nation);
          echo $thiscountry->getFlag();
        }
        else {
          print '&nbsp;';
        }
        ?>
      </td>
      <?php endif; ?>
      
      <td width="5px" style="text-align:center;">
        <?php echo ( isset($gamecount[$row->id] ) ) ? $gamecount[$row->id]->sum : 0 ; ?>
      </td>
      <?php foreach ($events AS $key => $ev) { ?>
      <td width="5px" style="text-align:center;">
        <?php echo ( isset($ev->stats[$row->id]->sum ) ) ? $ev->stats[$row->id]->sum : 0 ; ?>
      </td>
      <?php } ?>
    </tr>
    <?php
    $k = 1 - $k;
  }
	?>
	</tbody>
	<tfoot>
	 <tr>
	   <td colspan="<?php echo $colspan; ?>" style="text-align:right;"><?php echo 'Sum'; ?>
	   </td>
	   <?php foreach ($events AS $key => $ev) { ?>
	   <td style="text-align:center;"><?php echo $ev->sum; ?></td>
		 <?php } ?>
	 </tr>
	</tfoot>
	</table>
<?php
}
?>
<script type="text/javascript">
  // <![CDATA[
  // add links
  function init()
  {
    var Table1Sorter = new TSorter;
    Table1Sorter.init('projectreferees');
  }
      
  window.onload = init; 
// ]]>
</script>

<!-- Print Button START -->
<?php if ($overall_config['show_back_button'] > 0) {;?>
<?php if ($overall_config['show_back_button'] == "1") echo '<div align="left">'; else echo '<div align="right">';?>
<?php
$params = & new mosParameters( '' );
$params->def( 'back_button', true );
$params->def( 'popup', false );
mosHTML::BackButton( $params );
  echo "</div>";
};?>
<!-- Print Button END -->
</div>
